package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoGalleryDoor;
import com.muyu.danmo.service.IDanmoGalleryDoorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 画廊门头Controller
 *
 * @author yangle
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/galleryDoor")
public class DanmoGalleryDoorController extends BaseController
{
    @Autowired
    private IDanmoGalleryDoorService danmoGalleryDoorService;

    /**
     * 查询画廊门头列表
     */
//    @RequiresPermissions("system:galleryDoor:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoGalleryDoor>> list(DanmoGalleryDoor danmoGalleryDoor)
    {
        startPage();
        List<DanmoGalleryDoor> list = danmoGalleryDoorService.selectDanmoGalleryDoorList(danmoGalleryDoor);
        return getDataTable(list);
    }

    /**
     * 导出画廊门头列表
     */
//    @RequiresPermissions("system:galleryDoor:export")
    @Log(title = "画廊门头", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoGalleryDoor danmoGalleryDoor)
    {
        List<DanmoGalleryDoor> list = danmoGalleryDoorService.selectDanmoGalleryDoorList(danmoGalleryDoor);
        ExcelUtil<DanmoGalleryDoor> util = new ExcelUtil<DanmoGalleryDoor>(DanmoGalleryDoor.class);
        util.exportExcel(response, list, "画廊门头数据");
    }

    /**
     * 获取画廊门头详细信息
     */
//    @RequiresPermissions("system:galleryDoor:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoGalleryDoorService.selectDanmoGalleryDoorById(id));
    }

    /**
     * 新增画廊门头
     */
//    @RequiresPermissions("system:galleryDoor:add")
    @Log(title = "画廊门头", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoGalleryDoor danmoGalleryDoor)
    {
        return toAjax(danmoGalleryDoorService.insertDanmoGalleryDoor(danmoGalleryDoor));
    }

    /**
     * 修改画廊门头
     */
//    @RequiresPermissions("system:galleryDoor:edit")
    @Log(title = "画廊门头", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoGalleryDoor danmoGalleryDoor)
    {
        return toAjax(danmoGalleryDoorService.updateDanmoGalleryDoor(danmoGalleryDoor));
    }

    /**
     * 删除画廊门头
     */
//    @RequiresPermissions("system:galleryDoor:remove")
    @Log(title = "画廊门头", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoGalleryDoorService.deleteDanmoGalleryDoorByIds(ids));
    }
}
